import Vue from 'vue'
import VueRouter from 'vue-router'

// 一级路由
import Login from '@/views/Login'
import Register from '@/views/Register'
import Layout from '@/views/Layout'
import Favorate from '@/views/Favorate'
import City from '@/views/City'
import Map from '@/views/Map'

// 二级路由
import Home from '@/views/Layout/Home'
import List from '@/views/Layout/List'
import News from '@/views/Layout/News'
import My from '@/views/Layout/My'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    component: Login
  },
  {
    path: '/register',
    component: Register
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: Home
      },
      {
        path: '/home/list',
        component: List
      },
      {
        path: '/home/news',
        component: News
      },
      {
        path: '/home/profile',
        component: My
      }
    ]
  },
  {
    path: '/favorate',
    component: Favorate
  },
  {
    path: '/city',
    component: City
  },
  {
    path: '/map',
    component: Map
  },
]

const router = new VueRouter({
  routes
})

export default router
